<div class="content">

	<div class="list_button">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
        <tr>
            <td>
                <?php
					echo CHtml::link(
						"<div class='button'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-plus.png") .
							"</div>" .
							"<div style='float:left; min-width:80px;'>".
								"Thêm mới" .
							"</div>" .
						"</div>"
						,
                       array($this->controller_id."/add")
                    );
					
					echo "<div class='button' id='delete_multi'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-remove.png") .
							"</div>" .
							"<div style='float:left; min-width:40px;'>".
								"Xóa" .
							"</div>" .
						"</div>";
                ?>
                <script language="javascript">
					$(document).ready(function(){
						$('#delete_multi').click(function(){
							var form = document.getElementById("form_table_all");
							form.submit();
						});	
					})
              </script>
            </td>
          </tr>
        </table>
    </div>
    
    
    
    <table class="view">
        <tr height='25'>
            <th width="50px"> # </th>
            <th colspan="2" width="10">Action</th>
            <th>Admin Menu</th>
            <th width="80"> Bật / Tắt</th>
            <th width="80"> Mặc định</th>
            <th width="100">
				<?php 
					echo CHtml::link(
						"Thứ tự",
						array($controller_id."/set_order"),
						array("title"=>"Tạo thứ tự mặc định")
					);
					echo " ";
					echo CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-saveorder.png", "", 
						array("style"=>"cursor:pointer", "id"=>"id_save_order"));

				?>
            </th>
            <th width="250">Route</th>
            <th width="60">ID</th>
        </tr>
        <script language="javascript">
			$(document).ready(function(){
				$('#id_save_order').click(function() {
					var form = document.getElementById("form_table_all");
					var action = form.action;
					form.submit();
					//alert(action);
				});
			});
		</script>
        <?php
            if (! is_null($rows))
            {
                $i = 1;
				
				echo CHtml::beginForm(array($this->controller_id."/save_order"),
					"post", 
					array("id"=>"form_table_all")
				);
					
                foreach($rows as $row)
                {
                    show_row($row, $controller_id, $i );
                    $i++;
                    
                }
				echo CHtml::endForm();
            }
            
            function show_row($row, $controller_id, $i)
            {
                 echo "<tr>";
                    echo "<td align='center'>";
                        echo $i;
                    echo "</td>";
                    
                    echo "<td width='26px' align='center'>";
                      echo CHtml::link(
                            CHtml::image(Yii::app()->baseUrl.'/assets/icon/icon-16-trash.png'),
                            array(
                                $controller_id."/confirm_delete",
                                "adminmenu_id"=>$row["id"]
                            ),
                            array('title'=>'Delete')
                        );
                    echo "</td>";
                    
                    echo "<td width='26px' align='center'>";
                        echo CHtml::link(
                            CHtml::image(Yii::app()->baseUrl.'/assets/icon/icon-16-edit.png'),
                            array(
                                $controller_id."/edit",
                                "adminmenu_id"=>$row["id"]
                            ),
                            array('title'=>'Edit')
                        );
                    echo "</td>";
                    
                    echo "<td>";
						echo CHtml::image(
							Yii::app()->baseUrl.'/assets/images/adminmenu/'. $row->image,"",
							array("style"=>"width:18px; height: 18px", "align"=>"absmiddle")
						);
						
						echo "&nbsp;&nbsp;";
						
                        echo CHtml::link(	
                            $row["name"],
                            array(
                                $controller_id."/edit",
                                "adminmenu_id"=>$row["id"]
                            ),
                            array('title'=>'Edit')
                        );
                    echo "</td>";
                    
					echo "<td align='center'>";
                        $icons =  array(
                            0 => "icon-16-remove.png",
                            1 => "icon-16-tick.png",
                        );
                        echo CHtml::link(
                            CHtml::image(Yii::app()->baseUrl.'/assets/icon/'.$icons[$row["enable"]]),
                            array($controller_id."/enable", 
                                "adminmenu_id"=>$row["id"]
                            )
                        );
                    echo "</td>";
					
                    echo "<td align='center'>";
                        $icons =  array(
                            0 => "icon-16-nondefault.png",
                            1 => "icon-16-default.png",
                        );
                        echo CHtml::link(
                            CHtml::image(Yii::app()->baseUrl.'/assets/icon/'.$icons[$row["default"]]),
                            array($controller_id."/default", 
                                "adminmenu_id"=>$row["id"]
                            )
                        );
                    echo "</td>";
                    
                    echo "<td align='right'>";
						echo CHtml::textField(
							"order[".$row->id."]",
							$row->order,
							array("style"=>"width:40px; text-align:right; 
								padding:3px; color:#f00; font-size:11px;")
						);
						echo " ";
						
						
						echo CHtml::link(
							CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-up.png"),
							array(
								$controller_id."/up",  
								"adminmenu_id" => $row->id
							)
						);
						
						echo CHtml::link(
							CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-down.png"),
							array(
								$controller_id."/down", 
								"adminmenu_id" => $row->id,
							)
						);
						
                    echo "</td>";
                    
                    echo "<td>";
                        echo $row["route"];
                    echo "</td>";
                    
                    echo "<td align='center'>";
                        echo $row["id"];
                    echo "</td>";
                echo "</tr>";  	
            }
        ?>
    </table>
</div>